package com.iqiyi.pps.epg.core.dao.ticket;

import com.iqiyi.pps.epg.api.model.web.ticket.TTicketHistory;
import com.iqiyi.pps.epg.core.dao.base.BaseDao;
import com.iqiyi.pps.epg.core.model.ticket.TicketHistory;
import com.iqiyi.pps.epg.core.utils.DateTimeUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by karkarrotxu on 2017/8/29.
 */
@Component
public class TicketHistoryDao extends BaseDao<TicketHistory> {
    public TTicketHistory transToThrift(TicketHistory tempData) {
        TTicketHistory entity = new TTicketHistory();
        entity.setId(tempData.getId());
        entity.setDataId(tempData.getDataId());
        entity.setDataType(tempData.getDataType());
        entity.setDetail(tempData.getDetail());
        entity.setAddTime(DateTimeUtil.transLongFormat(tempData.getAddTime().getTime()));
        return entity;
    }

    public List<TTicketHistory> transToTList(List<TicketHistory> dataList) {
        List<TTicketHistory> resultList = new ArrayList<>();
        TTicketHistory entity = null;
        for (TicketHistory tempData : dataList) {
            entity = transToThrift(tempData);
            resultList.add(entity);
        }
        return resultList;
    }
}
